package com.xdl.flytest.util;


import java.util.LinkedHashMap;
import java.util.Map;

/**
 * @Auther: 80736
 * @Date: 2018/12/15 12:54
 * @Description:
 */


public enum ResponseMsg {

    SERVER_ERROR("server error", "504"),
    SUCCESS("Success", "200"),
    ERROR("Resource Not Fount", "404"),
    GATEWAY("Fuck Server", "502"),
    CREATE("Created", "201"),
    PARAMETER_ERROR("Parameter error", "10001");

    private String msg;
    private String code;

    private static LinkedHashMap<String, Object> map = new LinkedHashMap<>();


    ResponseMsg(String msg, String code) {
        this.msg = msg;
        this.code = code;
    }

    public static LinkedHashMap<String, Object> success() {
        LinkedHashMap<String, Object> map = new LinkedHashMap<>();
        map.put("code", ResponseMsg.SUCCESS.getCode());
        map.put("msg", ResponseMsg.SUCCESS.getMsg());
        return map;
    }

    public static LinkedHashMap<String, Object> result(ResponseMsg msg) {
        //LinkedHashMap<String, Object> map = new LinkedHashMap<>();
        map.put("code", msg.getCode());
        map.put("status", msg.getMsg());
        return map;
    }


    public static Map<String, Object> add(String key, Object value) {
        map.put(key, value);
        return map;
    }


    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }}
